package final_wearebatman_view;

import final_wearebatman_model.Inverter;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;

public class InverterView implements Ipaintable {

    private Inverter inverter;
    private CircuitView circuitview;
    private int posX;
    private int posY;
    private int angle;
    private String name;

    // konstruktor
    public InverterView(Inverter i, String name, CircuitView cv, int pX, int pY, int a) {
        this.inverter = i;
        this.circuitview = cv;
        this.posX = pX;
        this.posY = pY;
        this.angle = a;
        this.name = name;
    }

    // kirajzolas
    public void paint(Graphics2D g) {
        AffineTransform aT = g.getTransform();
        g.translate(posX, posY);
        g.rotate(this.angle * Math.PI / 180);
        g.drawLine(0, 8, 8, 8);
        g.drawLine(8, 1, 8, 15);
        g.drawLine(8, 1, 30, 8);
        g.drawLine(8, 15, 30, 8);
        g.drawOval(30, 3, 10, 10);
        g.drawLine(40, 8, 48, 8);
        g.setTransform(aT);
    }

    public int getPosX() {
        return this.posX;
    }

    public int getPosY() {
        return this.posY;
    }

    public int getAngle() {
        return this.angle;
    }

    public Point getInputPinPosition(int id) {
        Point p = new Point(0, 8);
        AffineTransform aT = new AffineTransform();
        aT.rotate(this.angle * Math.PI / 180);
        aT.transform(p, p);
        return new Point(posX+p.x, posY+p.y);
    }

    public Point getOutputPinPosition(int id) {
        Point p = new Point(48, 8);
        AffineTransform aT = new AffineTransform();
        aT.rotate(this.angle * Math.PI / 180);
        aT.transform(p, p);
        return new Point(posX + p.x, posY + p.y);
    }

    public Rectangle getClickArea() {
        return new Rectangle();
    }

    public void onClick() {

    }
}
